home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_07 / barbu / engine.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-17  |  1.6 KB  |  57 lines

  1. article\Listing3
  2.  
  3. #if !defined(ENGINE_HPP)
  4. #define ENGINE_HPP
  5. /////////////////////////////////////////////////////
  6. //    ENGINE + SYM definition, an abstract generator
  7. /////////////////////////////////////////////////////
  8. #include "STR.HPP"
  9.  
  10. class SYM {
  11. public:
  12.     virtual void set(const char szSym[], int nVal)= 0;
  13.     virtual int get(const char szSym[]) = 0 ;
  14.             // if szSym not found, should return 0
  15. };
  16.  
  17. class ENGINE {
  18.     enum { MAXLEN = 1024 };
  19. public:
  20.     ENGINE(const char szHppTemplate[],
  21.             const char szCppTemplate[]);
  22.     virtual ~ENGINE() {}
  23.  
  24.     void go(const char szTargetDir[],
  25.             const char szClass[], SYM* pSym
  26.             );
  27. protected:
  28.     static const char _Class[];
  29.     static const char _FlagOn[];
  30.     static const char _FlagOff[];
  31. private:
  32. // to be redefined for some presentation layer:
  33.     virtual void cannotOpen(
  34.                     const char szFileSpec[]) = 0;
  35.     virtual int overwriteQuest(
  36.                     const char szFileSpec[]) = 0;
  37.     virtual void unexpectedEOB(
  38.                     const char szFileSpec[],
  39.                     int nLine) = 0;
  40.     virtual void missingEOB(
  41.                     const char szFileSpec[],
  42.                     int nLine) = 0;
  43.     virtual void runEditor(
  44.                     const char szFileSpec[]) {}
  45.  
  46.     const STR _inHpp;
  47.     const STR _inCpp;
  48.     STR _inLine, _outLine, _stamp;
  49.  
  50.     void _fileJob(const char szInFile[],
  51.                 const char szOutFile[],
  52.                 const char newClass[], SYM *pSym
  53.                 );
  54.     const char* _substitute(const char newClass[]);
  55. };
  56. #endif
  57.